package weak_20241227_29.stream;

import java.util.ArrayList;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zdl
 * @date 2024/12/27
 */
public class Demo15 {
    public static void main(String[] args) {
        //15. 计算列表中每个元素出现的次数
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(1);
        list.add(3);
        list.add(2);
        list.add(3);
        list.add(1);
        Map<Integer, Long> collect = list.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
        System.out.println(collect);
    }
}
